package cn.itsource.hrm.web.controller;

import cn.itsource.hrm.document.CourseDoc;
import cn.itsource.hrm.query.CourseQuery;
import cn.itsource.hrm.service.ISearcherService;
import cn.itsource.hrm.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SearcherController {
    @Autowired
    private ISearcherService searcherService;

    /**
     * 保存和修改公用的
     * @param id  传递的参数
     * @return Ajaxresult转换结果
     */
    @RequestMapping(value="/onLineCourse",method= RequestMethod.POST)
    public AjaxResult onLineCourse(@RequestBody CourseDoc courseDoc){
        searcherService.save(courseDoc);
        return AjaxResult.me();
    }

    /**
     * 到ES搜索课程
     */
    @RequestMapping(value="/es/searchCourse",method= RequestMethod.POST)
    public AjaxResult searchCourse(@RequestBody CourseQuery query){

        AjaxResult result = searcherService.searchCourse(query);

        return result;

    }


}
